<template>
  <div class="LicenseInformation">
    <group title="请提交营业执照照片" class="ID">
        <img v-if="supplierData.business" :src="supplierData.business" alt="">
        <img v-else src="../assets/yingye.png" alt="">
        <input @change="getZp" name="idcard_zp" class="file" type="file" accept="image/*">
      </group>
      <div class="back">
        <x-button @click.native="back" type="primary">返回设置</x-button>
      </div>
  </div>
</template>
<script>
import { Group, XButton } from "vux";
export default {
  name: "LicenseInformation",
  data() {
    return {
      supplierData: {
        business: ""
      }
    };
  },
  components: {
    Group,
    XButton
  },
  methods: {
    getZp(e) {
      if (e.target.files.item(0)) {
        let formData = new FormData();
        let config = { headers: { "Content-Type": "multipart/form-data" } };
        formData.append("business", e.target.files[0]);
        this.$http
          .post("/api/com.upload/privacy_image", formData, config)
          .then(res => {
            this.supplierData.business = res.data.data.files;
          });
      }
    },
    back(){
      this.$router.go(-1)
    }
  },
  created() {
    this.$http.get("/api/supplier.supplier/read").then(res => {
      this.supplierData = res.data.data;
    });
  }
};
</script>

<style scoped lang="less">
.ID {
  position: relative;
  img {
    width: 80%;
    margin: 20px auto;
  }
  .file {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    opacity: 0;
  }
}
.back{
  padding: 15px;
}
</style>

